﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DreamOnGameEngine.Utils
{
    /// <summary>
    /// Just basic class to hold usefull addons to some classes
    /// </summary>
    public static class Addons
    {
        /// <summary>
        /// Converts a DateTime to a Unix timestamp
        /// </summary>
        /// <param name="value">Date Time to convert</param>
        /// <returns>Amount of Seconds since the UNIX Epoch</returns>
        public static double ConvertToTimestamp(this DateTime value)
        {
            //create Timespan by subtracting the value provided from
            //the Unix Epoch
            TimeSpan span = (value - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime());

            //return the total seconds (which is a UNIX timestamp)
            return (double)span.TotalSeconds;
        }
    }
}
